{% extends 'base.html' %}

{% block content %}
    <h2>Search</h2>
    <p>Put multiple words into quotes to do an exact search. <br>
       Using a - immediately before a term negates it.<br>
       Example: <code>goldfish "old one eye" -tank</code>
    </p>
    <form method="get" action=".">
        <table>
            {{ form.as_table }}
            <tr>
                <td>&nbsp;</td>
                <td>
                    <input type="submit" value="Search" class="button">
                </td>
            </tr>
        </table>
    </form>

    {% if page.object_list %}
        <h2>Found {{form.search.count}} match{{form.search.count|pluralize:"es"}}</h2>
        <dir>
        {% for result in page.object_list %}                
            <h3><a href="{{result.url}}">{{result.title}}</a></h3>
            <p>
            {{ result.text|process_search_result:form.q.data}}
        {% endfor %}
        </dir>
        {% with page as page_obj %}
        {% paginator %}
        {% endwith %}

    {% else %}
        <p>No results found.</p>
    {% endif %}

{% endblock %}